package com.turing.webosket.controller;

import com.turing.webosket.entity.User;
import com.turing.webosket.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

@Controller
public class WebSocket {
    @Autowired
    private UserMapper userMapper;
    //自己给自己发消息
    @GetMapping({"/index","/"})
    public String index(){
        User user = new User();
        user.setName("赵云云");
        user.setAge(11);
        userMapper.insert(user);
        return "index";
    }
    //自己给所有客户端发送消息
    @GetMapping({"/sendAllClient"})
    public String sendAllClient(){
        return "sendAllClient";
    }
    //自己给别的客户端发送消息
    @GetMapping({"/sendOtherClient"})
    public String sendOtherClient(){
        return "sendOtherClient";
    }
    public void saveUser() {
        User user = new User();
        user.setName("李丽丽");
        user.setAge(22);
        userMapper.insert(user);
    }
}